home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: howland.reston.ans.net!torn!nott!emr1!jagrant
- From: jagrant@emr1.emr.ca (John Grant)
- Subject: Re: simple design question
- Message-ID: <DM62yo.15p@emr1.emr.ca>
- Organization: Energy, Mines, and Resources, Ottawa
- References: <DM4u8I.G1H@emr1.emr.ca> <4etef2$3sc@newsroom.hitc.com>
- Date: Fri, 2 Feb 1996 21:13:36 GMT
-
- In article <4etef2$3sc@newsroom.hitc.com> psand@eos.hitc.com (G. Patrick Sand) writes:
- >In article <DM4u8I.G1H@emr1.emr.ca>, jagrant@emr1.emr.ca says...
- >>
- >>This is a design question, not a syntax question, so forgive the pseudo-
- >>code.
- >>
- >>I'm trying to design/write a class for complex file I/O (I'll state it
- >>in simple terms here).
- >>
- >>I want to use it like this:
- >> object.Open("xxx")
- >> for(...){
- >> object.Read(stuff);
- >> }
- >> object.Close();
- >>
- >>But I want to also have a single function that will Open/Read/Close in a
- >>single operation:
- >> object.GetData("xxx",stuff);
- >>
- >
- >Okay, the first question is this:
- >
- >1. Do you want to reuse the open/close/read semantics in other classes?
- >If so, make it a separate class and use inheritance to add it to classes
- >where you wish to do complex I/O. If not, just make them methods in the
- >desired class. I recommend that if you have 2 or more classes which will
- >do this I/O create the I/O operations as a separate class and
- >inherit--this is one of the maintenance blessing C++ and OOA/D confers on
- >you...if you use it...
- I was just thinking about this as a standalone class for now -it's
- actually complex enough now (I didn't supply the details).
- No, I can't see adding it to any other classes.
-
- No offence, but I don't think you've fully appreciated the specific
- question I originally asked. I won't repeat it again but it was
- related to the possible corruption by GetData() of internal stuff
- used by Open/Read/Close.
-
- >The second question is this:
- >
- >2. Why not use the iostreams/fstreams stuff? It does deal with
- [..perhaps but irrelevant for this problem and C streams are fine...]
- --
- John A. Grant jagrant@emr1.emr.ca
- Airborne Geophysics
- Geological Survey of Canada, Ottawa
-